import tuioZones.PointXY;


public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PointXY p = new PointXY(50,50);
		
		PointXY a = new PointXY(5,10);
		PointXY b = new PointXY(10,5);
		PointXY c = new PointXY(5,0);
		PointXY d = new PointXY(0,5);
		
		System.out.println(distanceToLine(a, b, p) <= b.distanceTo(c));
		System.out.println(distanceToLine(b, c, p) <= c.distanceTo(d));
		System.out.println(distanceToLine(c, d, p) <= d.distanceTo(a));
		System.out.println(distanceToLine(d, a, p) <= a.distanceTo(b));
	}
	
	public static double distanceToLine(PointXY p1, PointXY p2, PointXY push) {
		
		double kx = p2.getX() - p1.getX();
		double ky = p2.getY() - p1.getY();
		double k = ky / kx;
		
		double d = p1.getY() - p1.getX() * k;
		
		double dist = 0.0;
		double div = Math.sqrt(Math.pow(k,2) + 1);
		
		dist = (k * push.getX() + d - push.getY()) / div;
		
		return Math.abs(dist);
	}

}
